home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gigarom 1
/
Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso
/
FILES
/
DEV
/
I-Z
/
TransSkel.cpt
/
Skel.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1987-01-07
|
5KB
|
194 lines
{ TransSkel demonstration: Traditional Skel}
{ This program mimics the original Skel application: one sizable,}
{ dragable, non-closable dark gray window, an "About" alert and two}
{ dialogs. Desk accessories supported.}
{ The project should include this file, TransSkelPas (or a project}
{ built from TransSkel.c),MacPasLib, and MacTraps.}
{ 27 June 1986 Paul DuBois}
{ 1 January 1987 Ωhm Software - port to LS Pascal }
PROGRAM Skel;
USES
TransSkelPas;
CONST
{ Resource numbers}
fileMenuRes = 2; { File menu }
AboutAlrt = 1000; { About box }
theWindRes = 260; { window }
reportDlog = 257; { message dialog box }
aboutStr = 1; { message strings }
rattleStr = 2;
frightStr = 3;
{ file menu item numbers }
rattle = 1;
frighten = 2;
quit = 4;
TYPE
EventPtr = ^EventRecord;
VAR
theWind : WindowPtr;
{ Menu handles. There isn't any apple menu here, since TransSkel will}
{ be told to handle it itself.}
fileMenu : MenuHandle;
{ -------------------------------------------------------------------- }
{ Menu handling procedures }
{ -------------------------------------------------------------------- }
{ Read a string resource and put into the Alert/Dialog paramtext}
{ values}
PROCEDURE SetParamText (strNum : integer);
VAR
h : StringHandle;
BEGIN
h := GetString(strNum);
HLock(Handle(h));
ParamText(h^^, '', '', '');
HUnlock(Handle(h));
END;
{ Handle selection of "About Skel…" item from Apple menu}
PROCEDURE DoAbout;
VAR
h : StringHandle;
ignore : integer;
BEGIN
SetParamText(aboutStr);
ignore := Alert(aboutAlrt, NIL);
END;
{ Put up a dialog box with a message and an OK button. The message}
{ is stored in the 'STR ' resource whose number is passed as strNum.}
PROCEDURE report (strNum : integer);
VAR
theDialog : DialogPtr;
itemHit : integer;
BEGIN
SetParamText(strNum);
theDialog := GetNewDialog(Integer(reportDlog), Ptr(NIL), WindowPtr(-1));
ModalDialog(NIL, itemhit);
DisposDialog(theDialog);
END;
{ Process selection from File menu.}
{ Rattle, Frighten A dialog box with message}
{ Quit Request a halt by calling SkelHalt(). This makes SkelMain}
{ return.}
PROCEDURE DoFileMenu (item : integer);
BEGIN
CASE item OF
rattle :
Report(rattleStr);
frighten :
Report(frightStr);
quit :
SkelWhoa;
OTHERWISE
;
END;
END;
{ Initialize menus. Tell TransSkel to process the Apple menu}
{ automatically, and associate the proper procedures with the}
{ File and Edit menus.}
PROCEDURE SetUpMenus;
BEGIN
SkelApple('About Skel...', @DoAbout);
fileMenu := GetMenu(fileMenuRes);
SkelMenu(fileMenu, @DoFileMenu, NIL);
END;
{ -------------------------------------------------------------------- }
{ Window handling procedures }
{ -------------------------------------------------------------------- }
PROCEDURE WindActivate (active : Boolean);
BEGIN
DrawGrowIcon(theWind); { make grow box reflect new window state }
END;
{ On update event, can ignore the resizing information, since the whole}
{ window is always redrawn in terms of the current size, anyway.}
{ Content area is dark gray except scroll bar areas, which are white.}
{ Draw grow box as well.}
PROCEDURE WindUpdate (resized : Boolean);
VAR
r : Rect;
BEGIN
r := theWind^.portRect; { paint window dark gray }
r.bottom := r.bottom - 15; { don't bother painting the }
r.right := r.right - 15; { scroll bar areas }
FillRect(r, dkGray);
r := theWind^.portRect; { paint scroll bar areas white }
r.left := r.right - 15;
FillRect(r, white);
r := theWind^.portRect;
r.top := r.bottom - 15;
FillRect(r, white);
DrawGrowIcon(theWind);
END;
PROCEDURE WindHalt;
BEGIN
CloseWindow(theWind);
END;
{ Read window from resource file and install handler for it. Mouse}
{ and key clicks are ignored. There is no close proc since the window}
{ doesn't have a close box. There is no idle proc since nothing is}
{ done while the window is in front (all the things that are done are}
{ handled by TransSkel).}
PROCEDURE WindInit;
BEGIN
theWind := GetNewWindow(theWindRes, NIL, WindowPtr(-1));
SetPort(theWind);
SkelWindow(theWind, NIL, NIL, @WindUpdate, @WindActivate, NIL, @WindHalt, NIL, false);
END;
{ -------------------------------------------------------------------- }
{ Main }
{ -------------------------------------------------------------------- }
BEGIN
SkelInit; { initialize }
SetUpMenus; { install menu handlers }
WindInit; { install window handler }
SkelMain; { loop 'til Quit selected }
SkelClobber; { clean up }
END.